|
|
|
|
|
|
|
Example program Viewer uses the LoadPicture function to quickly view graphic files. The program's form contains DriveList, DirectoryList, and FileList controls that let you search your computer's files. When you click on a file in the FileList, the program uses LoadPicture to display the file. |
|
|
|
|
|
|
|
|
Example program Thumbs uses LoadPicture to display thumbnails of the files in a directory. It also uses DriveList, DirectoryList, and FileList controls to let you search your computer's files. When you select a directory and press F5, the program examines the files in its FileList control. For each file, the program uses LoadPicture to load the file into a hidden picture box. It then uses the PaintPicture method to copy the image at a reduced size into a visible thumbnail picture box. |
|
|
|
|
|
|
|
|
The Thumbs program is useful for managing directories full of graphic files. One other way the program helps is by allowing you to delete a file. If you click on a thumbnail and press the Delete key, the program moves the file into the system's wastebasket. |
|
|
|
|
|
|
|
|
The image, label, line, and shape controls are special objects that provide simple graphic features with low overhead. To keep their use of system resources low, these objects have fewer properties and methods than most other controls. They also do not have an hWnd property, which you need if you want to use the API functions described in Chapter 2. If you have simple drawing needs, however, these objects can help keep your use of system resources down and still save you the trouble of drawing your own graphics in Paint event handlers. |
|
|
|
|
|
|
|
|
These objects are in some sense not true controls. They do not use all the resources that other controls do. In particular, they are not drawn on their own windows. Instead they are drawn directly on the form or control that contains them. That saves resources, but it also means they cannot be placed above other controls. For example, a label control cannot lie on top of a text box within the same container. If you really need to place a label over a text box, you can place the label inside a borderless picture box and place the picture box on top of the text box. |
|
|
|
|
|
|
|
|
The following sections describe the graphic controls in more detail. |
|
|
|
|
|
|
|
|
The image control is a lightweight version of the picture box control. It uses fewer system resources and repaints more quickly than a picture box control, but it has only some of the picture box's properties, methods, and events. In particular, the image control does not have Line, Circle, PaintPicture, PSet, Point, or Print methods. Because they have such limited capabilities, image controls are usually used either to display pictures or to hold pictures that are copied into a picture box for further manipulation. |
|
|
|
|
|
|
|
|
Image controls have one important property that picture boxes do not: Stretch. If Stretch is true, the picture you load into the image control stretches to fill the control. If Stretch is false, the control resizes to fit the picture. |
|
|
|
|
|